<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="月份" prop="yearMonth">
                <el-select v-model="queryParams.yearMonth" placeholder="请选择月份">
                    <el-option v-for="item in yearMonthList" :label="item" :key="item" :value="item" />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading" @click="handleExport" v-hasPermi="['business:outFactory:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="incerateHandleList">
            <el-table-column label="日期" align="center" prop="date" width="120" />
            <el-table-column v-for="item in columList" :key="item.wasteId" :label="item.wasteName" align="center" :prop="item.wasteId" min-width="150" />
        </el-table>

        <!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> -->

    </div>
</template>

<script>
import { incinerateHandleReport, exportIncinerateHandleReport, yearMonthList } from "@/api/business/report.js";


export default {
    name: "IncinerateHandleReport",
    components: {
    },
    data() {
        return {
            //按钮loading
            buttonLoading: false,
            // 遮罩层
            loading: true,
            // 导出遮罩层
            exportLoading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 焚化处置表格数据
            incerateHandleList: [],
            // 焚化处置危废信息
            columList: [],
            // 出厂日期范围
            daterangeOutFactoryDate: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                wasteId: undefined,
                wasteName: undefined,
                batchNumber: undefined,
                handleCompanyKey: undefined,
                outFactoryDate: this.parseTime(new Date()),
                yearMonth: this.parseTime(new Date(),  '{y}-{m}')
            },
            yearMonthList: [],
        };
    },
    created() {
        this.getList();
        this.getYearMonthList();
    },
    methods: {
        /** 查询委外出厂列表 */
        getList() {
            this.loading = true;
            this.queryParams.params = {};
            incinerateHandleReport(this.queryParams).then(response => {
                this.columList = response.wasteList;
                this.incerateHandleList = response.dataList;
                this.loading = false;
            });
        },
        /** 获取年月列表 */
        getYearMonthList() {
            yearMonthList().then((response) => {
                this.yearMonthList = response;
            });
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.daterangeOutFactoryDate = [];
            this.resetForm("queryForm");
            this.queryParams.yearMonth = this.parseTime(new Date(),  '{y}-{m}');
            this.handleQuery();
        },

        /** 导出按钮操作 */
        handleExport() {
            const queryParams = this.queryParams;
            this.$confirm('是否确认导出?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                this.exportLoading = true;
                return exportIncinerateHandleReport(queryParams);
            }).then(response => {
                this.download(response.msg);
                this.exportLoading = false;
            }).catch(() => { });
        },
    }
};
</script>